package com.maple.blog.config.server;

import com.maple.blog.bean.ResponseBean;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 描述: com.maple.blog.config.server
 *
 * @author hz.lei
 * @date 2018年04月27日 下午11:31
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    private static final Logger log = LogManager.getLogger(GlobalExceptionHandler.class);

    @ExceptionHandler({Exception.class})
    @ResponseBody
    public ResponseBean handleException(Exception exception) {
        log.error(exception.getMessage(), exception);
        return ResponseBean.error(exception);
    }

    public GlobalExceptionHandler() {
    }
}
